﻿using System;
using System.Collections.Generic;
using System.Domain.Entity;
using System.Domain.IRepository;
using System.Text;
using Application.Infrastructure;
using Domain.Infrastructure;

namespace System.Application
{

    public interface ISysOperationLogService
    {
        bool WriteDbLog(SysOperationLogEntity entity);
        List<SysOperationLogEntity> GetList(Pagination pagination, string userId, DateTime start, DateTime end);
    }
    /// <summary>
    ///用户操作日志服务 
    /// </summary>	
    public class SysOperationLogService : BaseService_C<SysOperationLogEntity>, ISysOperationLogService
    {
        private readonly ISysOperationLogRepository _repository;
        public SysOperationLogService(ILog log, ISysOperationLogRepository repository) : this(log, repository, "")
        {
        }
        public SysOperationLogService(ILog log, ISysOperationLogRepository repository, string userId) : base(log, repository, userId)
        {
            _repository = repository;
        }

        public bool WriteDbLog(SysOperationLogEntity entity)
        {
            return Insert(entity);
        }

        public List<SysOperationLogEntity> GetList(Pagination pagination, string userId, DateTime start, DateTime end)
        {
            try
            {
                return _repository.GetList(pagination, userId, start, end);

            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }

        }


    }
}
